<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>ECharts-series-系列图-type-pie</title>
  </head>
  <body>
    <div id="main" style="height: 400px"></div>
    <script src="../libs/echarts-5.3.3.js"></script>
    <script>
      window.onload = function () {
        const myChart = echarts.init(document.getElementById("main"));
        const option = {
          // 标题组件
          title: {
            text: "ECharts-pie",
            subtext: "饼图",
            left: "center",
          },
          // 提示框组件
          tooltip: {
            trigger: "item",
            formatter: "{a} <br/>{b} : {c} ({d}%)",
          },
          // 图例组件
          legend: {
            orient: "vertical",
            left: "left",
          },
          series: [
            {
              type: "pie", // 系列类型: 饼图
              label: {
                // 标签配置
                show: true,
              },
              // center: ["50%", "50%"], // 圆心坐标
              radius: ["0%", "80%"], // 饼图的半径。数组的第一项是内半径，第二项是外半径。
              roseType: "area", // 是否展示成南丁格尔图
              data: [
                {
                  value: 5,
                  name: "衬衫", // 数据项名称, 比如pie系列 tooltip 需要用到
                },
                {
                  value: 20,
                  name: "羊毛衫",
                },
                {
                  value: 36,
                  name: "雪纺衫",
                },
                {
                  value: 10,
                  name: "裤子",
                },
                {
                  value: 10,
                  name: "高跟鞋",
                },
                {
                  value: 20,
                  name: "袜子",
                },
              ],
            },
          ],
        };
        myChart.setOption(option);
      };
    </script>
  </body>
</html>
